home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWViews / Include / FWContrH.h < prev    next >
Encoding:
Text File  |  1996-08-16  |  7.1 KB  |  220 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWContrH.h
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #if    defined(FW_BUILD_MAC) && !defined(FWCONTRH_H)
  11. #define FWCONTRH_H
  12.  
  13. // ----- OS Layer -----
  14.  
  15. #ifndef FWRECT_H
  16. #include "FWRect.h"
  17. #endif
  18.  
  19. // ----- Macintosh Includes -----
  20.  
  21. #if defined(FW_BUILD_MAC) && !defined(__CONTROLS__)
  22. #include <Controls.h>
  23. #endif
  24.  
  25. //========================================================================================
  26. // Forward declarations
  27. //========================================================================================
  28.  
  29. class    FW_CNativeControl;
  30. class     FW_CFont;
  31. class    FW_CScrollBar;
  32. class   FW_CPopupMenu;
  33. class    FW_CString;
  34. class    FW_SPrivControlOwner;
  35. class     ODFacet;
  36. class     FW_CAcquireCFMResourceAccess;
  37. class    FW_CViewContext;
  38.  
  39. //========================================================================================
  40. //    CLASS FW_CPrivMacControlHelper
  41. //========================================================================================
  42.  
  43. class FW_CPrivMacControlHelper
  44. {
  45. public:
  46. //    FW_DECLARE_CLASS
  47.  
  48. // ----- Initialization/destruction
  49. public:
  50.     FW_CPrivMacControlHelper(Environment* ev, FW_CNativeControl* control,
  51.                                     short value, short min, 
  52.                                     short max, short procID,
  53.                                     const Str255 label,
  54.                                     const FW_CFont& font,
  55.                                     long refCon = 0);
  56.     virtual     ~FW_CPrivMacControlHelper();
  57.     
  58. public:
  59.     ControlHandle            GetControlHandle() const;
  60.                                     
  61.     void                    SetControlMargin(short margin);
  62.     
  63.     void                    SetBounds(const FW_CPlatformRect& controlBounds);
  64.     void                    GetBounds(FW_CPlatformRect& controlBounds) const;
  65.         
  66.     void                    SetValue(short value, 
  67.                                      const FW_CPlatformPoint& location,
  68.                                      const FW_CPlatformPoint& size);
  69.     void                    SetValue(short value, FW_Boolean drawNow);
  70.     short                    GetValue() const;
  71.     void                    SetMin(short min);
  72.     short                    GetMin() const;
  73.     void                    SetMax(short max);
  74.     short                    GetMax() const;
  75.     void                    SetText(const FW_CString& text);
  76.     void                    GetText(FW_CString& text) const;
  77.  
  78.     FW_CNativeControl*        GetControl() const;
  79.  
  80.     void                    Draw(Environment* ev,
  81.                                     ODFacet* facet, 
  82.                                     const FW_CPlatformPoint& location,
  83.                                     const FW_CPlatformPoint& size);
  84.     void                     Print(Environment* ev, ODFacet* facet, 
  85.                                     const FW_CPlatformPoint& location,
  86.                                     const FW_CPlatformPoint& size);
  87.     void                     Enable(FW_Boolean enabled, const FW_CPlatformPoint& location,
  88.                                     const FW_CPlatformPoint& size);
  89.     void                     Enable(FW_Boolean enabled);
  90.     void                     Show(const FW_CPlatformPoint& location,
  91.                                     const FW_CPlatformPoint& size);
  92.     void                     Show();
  93.     void                     Hide();
  94.     Boolean                    MouseDown(Environment* ev, const FW_CViewContext& vc,
  95.                                     const FW_CPlatformPoint& whereMouse);
  96.     void                     SimulateButtonPressed(const FW_CPlatformPoint& location,
  97.                                     const FW_CPlatformPoint& size);
  98.  
  99.     virtual FW_Boolean         PartCodeSwitch(Environment* ev, 
  100.                                             const FW_CViewContext& vc,
  101.                                             const FW_CPlatformPoint& whereMouse, 
  102.                                             short partCode);
  103.  
  104. private:
  105.     void                    Initialize(Environment* ev, short value, short min, short max, 
  106.                                     const Str255 label, const FW_CFont& font, long refCon);
  107.  
  108.     void                     DrawControl(Environment* ev, ODFacet* facet);
  109.     void                    SetupControl(const FW_CPlatformPoint& location,
  110.                                          const FW_CPlatformPoint& size);
  111.  
  112.     FW_CAcquireCFMResourceAccess* OpenResFileForPopup(Environment* ev);
  113.  
  114. protected:
  115.     FW_CNativeControl*        fControl;    
  116.     ControlHandle            fControlHandle;        // Mac control
  117.     short                    fControlMargin;        // Used for drawing default button
  118.     short                    fMacProcId;    
  119.     short                    fMacFontId;            // = 0 if controls uses default font
  120.     short                    fMacFontStyle;    
  121.     short                    fMacFontSize;        
  122. };
  123.  
  124. //========================================================================================
  125. //    CLASS FW_CPrivMacScrollBarControlHelper
  126. //========================================================================================
  127.  
  128. class FW_CPrivMacScrollBarControlHelper : public FW_CPrivMacControlHelper
  129. {
  130. public:
  131.     FW_CPrivMacScrollBarControlHelper(Environment* ev, 
  132.                                     FW_CNativeControl* control,
  133.                                     short value, 
  134.                                     short min, 
  135.                                     short max, 
  136.                                     long refCon = 0);
  137.     virtual ~FW_CPrivMacScrollBarControlHelper();
  138.  
  139.     virtual FW_Boolean         PartCodeSwitch(Environment* ev, 
  140.                                         const FW_CViewContext& vc,
  141.                                         const FW_CPlatformPoint& whereMouse, 
  142.                                         short partCode);
  143.  
  144. private:
  145.     static pascal void        CallActionProc(ControlHandle controlHandle,  short partCode);
  146.     void                    ActionProc(short partCode);    
  147.     
  148. private:
  149.     ODFacet*        fFacet;
  150. };
  151.  
  152. //========================================================================================
  153. //    Inlines
  154. //========================================================================================
  155.  
  156. //----------------------------------------------------------------------------------------
  157. // FW_CPrivMacControlHelper::GetControlHandle
  158. //----------------------------------------------------------------------------------------
  159.  
  160. inline ControlHandle FW_CPrivMacControlHelper::GetControlHandle() const
  161. {
  162.     return fControlHandle;
  163. }
  164.  
  165. //----------------------------------------------------------------------------------------
  166. // FW_CPrivMacControlHelper::GetBounds
  167. //----------------------------------------------------------------------------------------
  168.  
  169. inline void FW_CPrivMacControlHelper::GetBounds(FW_CPlatformRect& controlBounds) const
  170. {
  171.     controlBounds = (*fControlHandle)->contrlRect;
  172. }
  173.  
  174. //----------------------------------------------------------------------------------------
  175. // FW_CPrivMacControlHelper::GetValue
  176. //----------------------------------------------------------------------------------------
  177.  
  178. inline short FW_CPrivMacControlHelper::GetValue() const
  179. {
  180.     return ::GetControlValue(fControlHandle);
  181. }
  182.  
  183. //----------------------------------------------------------------------------------------
  184. // FW_CPrivMacControlHelper::GetMin
  185. //----------------------------------------------------------------------------------------
  186.  
  187. inline short FW_CPrivMacControlHelper::GetMin() const
  188. {
  189.     return ::GetControlMinimum(fControlHandle);
  190. }
  191.  
  192. //----------------------------------------------------------------------------------------
  193. // FW_CPrivMacControlHelper::GetMax
  194. //----------------------------------------------------------------------------------------
  195.  
  196. inline short FW_CPrivMacControlHelper::GetMax() const
  197. {
  198.     return ::GetControlMaximum(fControlHandle);
  199. }
  200.  
  201. //----------------------------------------------------------------------------------------
  202. // FW_CPrivMacControlHelper::GetControl
  203. //----------------------------------------------------------------------------------------
  204.  
  205. inline FW_CNativeControl* FW_CPrivMacControlHelper::GetControl() const
  206. {
  207.     return fControl;
  208. }
  209.  
  210. //----------------------------------------------------------------------------------------
  211. // FW_CPrivMacControlHelper::SetControlMargin
  212. //----------------------------------------------------------------------------------------
  213.  
  214. inline void FW_CPrivMacControlHelper::SetControlMargin(short controlMargin)
  215. {
  216.     fControlMargin = controlMargin;
  217. }
  218.  
  219. #endif
  220.